<?php

namespace fabriek\verf;

class BodyPanel extends \fabriek\Moeder {
    private $_bodies = array(
       'body_01'=>array('kleur'=>'diepzwart','meerprijs'=>0),
        'body_02'=>array('kleur'=>'kristalwit','meerprijs'=>0),
        'body_03'=>array('kleur'=>'rallyrood','meerprijs'=>0),
        'body_04'=>array('kleur'=>'flame yellow','meerprijs'=>0),
        'body_05'=>array('kleur'=>'zilver','meerprijs'=>366.63),
        'body_06'=>array('kleur'=>'lichtblauw','meerprijs'=>366.63),
        'body_07'=>array('kleur'=>'mat antraciet','meerprijs'=>508.20)
    );
    
    public function zet($body = "") {
        if (!empty($body) && array_key_exists($body,$this->_bodies)) {
            $_SESSION['BodyPanel'] = $body;
        } else {
            $this->reset();
        }
    }
    
    public function reset() {
        reset($this->_bodies);
        $_SESSION['BodyPanel'] = key($this->_bodies);
    }
    
    public function opties() {
        $html ='';
        foreach ($this->_bodies as $body=> $tmp) {
            $kleur = $tmp['kleur'];
            $prijs = $tmp['meerprijs'];
            $foto = 'images/'.$_SESSION['Model'].'/'.$body.'.png';
            $html .= <<<EOD
        <a href="{$body}" class="optieItem">
            <img src="{$foto}" >
            <h3>{$kleur}</h3>
            <h4>&euro;{$prijs}</h4>
        </a>    
EOD;
        }
        return $html;
    }
    
    public function samenvatting() {
        $body = $_SESSION['BodyPanel'];
        $prijs = $this->_bodies[$body]['meerprijs'];
        $kleur = $this->_bodies[$body]['kleur'];
        return array('optie'=>$kleur,'prijs'=>$prijs);
    }
    
    public function afbeelding() {
        return "images/".$_SESSION['Model'].'/'.$_SESSION['BodyPanel'].'.png';
    }
}
